package cn.mengfly.fxtest.app;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;

/**
 * @author Mengfly
 * @date 2021/5/28 9:30
 */
public class LineChartApp extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        XYChart.Series<Number, Number> series = new XYChart.Series<>();
        series.getData().add(new XYChart.Data<>(0.0, 0.0));
        series.getData().add(new XYChart.Data<>(0.7, 0.5));
        series.getData().add(new XYChart.Data<>(1.0, 0.632));
        series.getData().add(new XYChart.Data<>(2.0, 0.865));
        series.getData().add(new XYChart.Data<>(3.0, 0.95));
        series.getData().add(new XYChart.Data<>(4.0, 0.982));
        series.getData().add(new XYChart.Data<>(5.0, 0.993));


        LineChart<Number, Number> lineChart = new LineChart<>(
                new NumberAxis("Time Constant", 0.0, 5.0, 1),
                new NumberAxis("Voltage(Vs)", 0.0, 1.0, 0.1)
        );
        lineChart.getData().add(series);
        lineChart.setTitle("RC Charging");
        lineChart.setStyle("-fx-background-color: lightgray");
        lineChart.setCreateSymbols(false);
        lineChart.setLegendVisible(false);

        Scene scene = new Scene(lineChart);

        primaryStage.setScene(scene);
        primaryStage.setTitle("LineChartApp");
        primaryStage.show();

    }


}
